package com.atguigu.springcloud.enums;

/**
 * add by lizhilong
 * 根据Code获取相应的枚举
 */
public class EnumUtil {
    public static <O, T extends CommonEnum> T getByCode(O o, Class<T> enumClass) {
        for (T each : enumClass.getEnumConstants()) {
            if (o.equals(each.getCode())) {
                return each;
            }
        }
        return null;
    }
}
